from start import db
from datetime import datetime

class BaseModel(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)


class User(BaseModel):
    __tablename__ = 'users'
    username = db.Column(db.String(80), unique=True, nullable=False, comment='用户名')
    password = db.Column(db.String(120), nullable=False,comment='密码')
    last_login = db.Column(db.DateTime, default=datetime.utcnow)
    nicknane = db.Column(db.String(80), comment='昵称')
    avatar_path = db.Column(db.String(120), comment='头像路径')
    # posts = db.relationship('Post', backref='author')
class BlogInfo(BaseModel):
    __tablename__ = 'blog_info'
    title = db.Column(db.String(80),comment='网站标题')
    subtitle = db.Column(db.String(80),comment='网站副标题')
    about_me = db.Column(db.Text,comment='关于我')
